package ooday02;

public class AnimalTesting {
    public static void main(String[] args) {



        Animal a=new Dog("大黄狗",2,"黄色");//向上造型
        a.eat();
        a.drink();


        Dog gg=(Dog)a;//向下造型 强转
        gg.swim();
        gg.special();//调用派生类特有方法

        Animal a1=new Chick("大红鸡",8,"红色");//向上造型
        Chick ck=(Chick) a1;//向下造型 子类对象指向父类  强转
        ck.layEggs();
        a1.eat();
        a1.drink();

        Dog g=new Dog("小黑狗",7,"黑色");
        g.drink();
        g.eat();
        g.special();

        Chick cc=new Chick("花花",2,"五颜六色");

        Animal a2=new Fish("大金鱼",3,"金色");//父类对象引用指向子类 向上造型
        a2.eat();
        a2.drink();
        Fish f=(Fish) a2;//向下造型 子类对象引用指向父类
        f.swim();
    }
}
